package com.carlinfo.common.servlet;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.carlinfo.common.util.DateUtile;
import com.carlinfo.common.util.EncryptUtil;
import com.carlinfo.common.util.IOUtil;
import com.carlinfo.common.util.PageInfoUtil;
import com.carlinfo.common.util.RegexUtil;

/**
 * 所有Service的公共的代码
 * @author WangshMac
 */
public class BaseServlet extends HttpServlet
{
	protected Logger logger = LogManager.getLogger() ; 
	protected DateUtile dateUtil = new DateUtile() ; 
	protected IOUtil ioUtil = new IOUtil();
	protected EncryptUtil encryptUtil = new EncryptUtil() ;
	protected RegexUtil regexUtil = new RegexUtil() ;
	
	/**
	 * 分页
	 */
	public PageInfoUtil proccedPageInfo(HttpServletRequest request)
	{
		/* 为了实现分页;
		 * 所需要的数据写活,问发信人的信里面要
		 * 取信的内容
		 * ?a=1&b=2&c=3
		 *  */
		String currentPage = request.getParameter("currentPage");
		String pageSize = request.getParameter("pageSize");
		
		/* 查询10条 */
		PageInfoUtil pageInfoUtil = new PageInfoUtil() ; 
		try
		{
			/* 如果currentPage发信人木有传,就是null;知道会报,
			 * try一下,异常不打印
			 *  */
			/* 每页10条, */
			pageInfoUtil.setPageSize(Integer.valueOf(pageSize));
			/* 第一页 */
			pageInfoUtil.setCurrentPage(Integer.valueOf(currentPage));
		} catch (NumberFormatException e)
		{
		}
		return pageInfoUtil ; 
	}
}
